import org.gradle.api.Plugin
import org.gradle.api.Project
import org.gradle.api.tasks.compile.JavaCompile
import org.gradle.kotlin.dsl.dependencies
import java.io.File

class CompileFrameworkPlugin : Plugin<Project> {
    override fun apply(target: Project) {
        with(target) {
            gradle.projectsEvaluated {
                tasks.withType(JavaCompile::class.java) {
                    val fileList = ArrayList<File>()
                    fileList.add(File("libs/framework.jar")) // JAVA语法，可连续调用，输入参数建议为相对路径
                    fileList.addAll(options.bootstrapClasspath?.files ?: emptySet()) // 最后将原始参数添加
                    options.bootstrapClasspath = files(fileList.toArray())
                }
            }

            dependencies {
                add("compileOnly", files("libs/framework.jar"))
            }
            //compileOnly files('libs/framework.jar')
        }
    }
}
